package utils;

import objects.Card;
import objects.CardType;
import objects.Character;
import objects.Room;
import objects.Weapon;

public class CaseMachine 
{

	/**
	 *  Characters Enum generator from strings.
	 */
	public static Character getCharFromString(String charName)
	{
		Character charToReturn = null;
	    switch (charName) 
	    {
	        case "Miss Scarlett":  	charToReturn = Character.MISS_SCARLETT;
	                 break;
	        case "Reverend Green":  charToReturn = Character.REVEREND_GREEN;
	        		break;
	        case "Professor Plum":  charToReturn = Character.PROFFESOR_PLUM;
	        		break;
	        case "Colonel Mustard": charToReturn = Character.COLONEL_MUSTARD;
	        		break;
	        case "Mrs. White":  	charToReturn = Character.MRS_WHITE;
	        		break;
	        case "Mrs. Peacock ":  	charToReturn = Character.MRS_PEACOCK;
	        		break;
	        case "Mrs. Peacock":  	charToReturn = Character.MRS_PEACOCK;
					break;
	    }
	
	    return charToReturn;
	}

	/**
	 * get enum from the string. handle different versions accordingly.
	 */
	public static Room getRoomFromString(String roomName)
	{
		Room roomToReturn = null;
	    switch (roomName) 
	    {
	        case "DINING ROOM":  	roomToReturn = Room.DINING_ROOM;
	        		break;
	        case "BILLIARD ROOM":  	roomToReturn = Room.BILLIARD_ROOM;
	        		break;
			default:	roomToReturn = Room.valueOf(roomName);
	    }
	
	    return roomToReturn;
	}

	public static CardType getCardTypeFromString(String cardType)
	{
		CardType crdType = null;
	    switch (cardType) 
	    {
	        case "suspect":
	        	{
	        		crdType = CardType.valueOf("CHARACTER");
	        		break;
	        	}
	    	default:
	    	{
	    		crdType = CardType.valueOf(cardType.toUpperCase());
	    		break;
	    	}
	        		
	    }
	    return crdType;
	}

	// Get weapon enum from string. hadling non-default names accordingly.
	public static Weapon getWeaponFromString(String weaponName)
	{
		Weapon weaponToReturn = null;
	    switch (weaponName) 
	    {
	        case "LEAD PIPE":  		weaponToReturn = Weapon.LEAD_PIPE;
	                 break;
	        default:  	weaponToReturn = Weapon.valueOf(weaponName);
					break;
	    }
	
	    return weaponToReturn;
	}

	public static String getCardVal(Card card)
	{
		String strCardValue = null;
		
		switch (card.getType())
		{
		case WEAPON: strCardValue = getWeaponFromCard(Weapon.valueOf(card.getName()));
			break;
		case ROOM: strCardValue = getRoomFromCard(Room.valueOf(card.getName()));
			break;
		case CHARACTER: strCardValue = getCharFromCard(Character.valueOf(card.getName()));
			break;
		}
		
		return strCardValue;
	}

	// Characters Enum generator from strings.
	public static String getCharFromCard(Character character)
	{
		String charToReturn = null;
	    switch (character) 
	    {
	        case MISS_SCARLETT:  	charToReturn = "Miss Scarlett";
	                 break;
	        case REVEREND_GREEN:  charToReturn = "Reverend Green";
	        		break;
	        case PROFFESOR_PLUM:  charToReturn = "Professor Plum";
	        		break;
	        case COLONEL_MUSTARD: charToReturn = "Colonel Mustard";
	        		break;
	        case MRS_WHITE:  	charToReturn = "Mrs. White";
	        		break;
	        case MRS_PEACOCK:  	charToReturn = "Mrs. Peacock ";
	        		break;
	    }
	
	    return charToReturn;
	}

	// get enum from the string. handle different versions accordingly.
	public static String getRoomFromCard(Room room)
	{
		String roomToReturn = null;
	    switch (room) 
	    {
	        case DINING_ROOM:  	roomToReturn = "DINING ROOM";
	        		break;
	        case BILLIARD_ROOM:  	roomToReturn = "BILLIARD ROOM";
	        		break;
			default:	roomToReturn = room.name();
	    }
	
	    return roomToReturn;
	}

	// Get weapon enum from string. hadling non-default names accordingly.
	public static String getWeaponFromCard(Weapon weapon)
	{
		String weaponToReturn = null;
	    switch (weapon) 
	    {
	        case LEAD_PIPE:  		weaponToReturn = "LEAD PIPE";
	                 break;
	        default:  	weaponToReturn = weapon.name();
					break;
	    }
	
	    return weaponToReturn;
	}
	
	public static String getImgFromRoom(Room room)
	{
		String src = null;
		
		switch (room) 
		{
			case KITCHEN: src="kitchenCard.png"; 
				break;
			case BALLROOM: src="ballroomCard.png"; 
				break;
			case BILLIARD_ROOM: src="billiardRoomCard.png"; 
				break;
			case CONSERVATORY: src="conservatoryCard.png"; 
				break;
			case DINING_ROOM: src="diningRoomCard.png"; 
				break;
			case LIBRARY: src="libraryCard.png"; 
				break;
			case LOUNGE: src="loungeCard.png"; 
				break;
			case STUDY: src="studyCard.png"; 
				break;
			case HALL: src="hallCard.png"; 
				break;
		}
		return src;
	}
	
	public static String getImgFromCharacter(Character character)
	{
		String src = null;
		
		switch (character) 
		{
			case REVEREND_GREEN: src="greenCard.png";
			break;
			case MRS_WHITE: src="whiteCard.png";
			break;
			case MRS_PEACOCK: src="peacockCard.png";
			break;
			case MISS_SCARLETT: src="scarlettCard.png";
			break;
			case PROFFESOR_PLUM: src="plumCard.png";
			break;
			case COLONEL_MUSTARD: src="mustardCard.png";
			break;
		}
		
		return src;
	}
	
	public static String getImgFromWeapon(Weapon weapon)
	{
		String src = null;
		
		switch (weapon) 
		{
			case WRENCH: src="spannerCard.png";
				break;
			case REVOLVER: src="revolverCard.png";
				break;
			case DAGGER: src="daggerCard.png";
				break;
			case CANDLESTICK: src="candlestickCard.png";
				break;
			case ROPE: src="ropeCard.png";
				break;
			case LEAD_PIPE: src="leadpipeCard.png";
				break;
		}
		
		return src;
	}
	
}
